﻿using EasyNetQ;

namespace Framework.Infrastructure.RabbitMQ
{
    /// <summary>
    /// RabbitMQ发布者
    /// </summary>
    public class RabbitPublisher
    {
        private static string mq_host = Common.GetAppSetting("rabbitmq_host");
        private static string user = Common.GetAppSetting("rabbitmq_user");
        private static string pwd = Common.GetAppSetting("rabbitmq_pwd");

        /// <summary>
        /// RabbitMQ消息发布
        /// </summary>
        public static void Publish(RabbitModel_Base rabbitModel)
        {
            using (var bus = RabbitHutch.CreateBus(string.Format("host={0};username={1};password={2}", mq_host, user, pwd)))
            {
                bus.Publish(rabbitModel);
            }
        }

    }
}
